package org.example.config;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

import java.util.Date;

@Component
public class LoggingFilterConfig implements GlobalFilter {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

//        前置
        System.out.println("前置当前时刻"+new Date().getTime());
        Mono<Void> filter = chain.filter(exchange);
//        后置
        System.out.println("后置当前时刻"+new Date().getTime());
        return filter;
    }
}
